and build the foundation for a successful scripting career.
What is statistical programming?
Broadly speaking, computer programming differs from statistical programming in the following way:
Computer programming is more focused on software development.
Statistical programming is more focused on data analysis and the communication of the results.
R is a language and environment for statistical computing and for graphics
GNU project (100% free software)
Managed by the R Foundation for Statistical Computing, Vienna, Austria.
Community-driven
Based on the object-oriented language S (1975)
R works with objects that consist of elements. The smallest elements are numbers and characters.
Everything that is published on the Comprehensive R
Archive Network (CRAN) and is aimed at R users, must be
accompanied by a help file.
If you know the name of the function that performs an operation,
e.g. anova(), then you just type ?anova or
help(anova) in the console.
If you do not know the name of the function: type ??
followed by your search criterion. For example ??anova
returns a list of all help pages that contain the word ‘anova’
Alternatively, the internet will tell you almost everything you’d
like to know and sites such as http://www.stackoverflow.com and http://www.stackexchange.com, as well as
Google can be of tremendous help.
R related issues; use ‘R:’ as a prefix in
your search termAssigning things in R is very straightforward:
<-For example, if you assign the value 100 (an
element) to object a, you would type
a <- 100
When reading that code say: “a gets value 100” in your head.
Good coding practice:
<- is a pain to type, but don’t use
= instead, it will work, but it will cause confusion
later.
Use RStudio’s keyboard shortcut: Alt (or Option) + -
(the minus sign).
Notice that RStudio automatically surrounds <-
with spaces (good code formatting practice).
Calling things in R is also very straightforward:
For example, we assigned the value 100 to object
a. To call object a, we would type
a
## [1] 100
This is why we use R-Studio.
RStudioRStudio ProjectsEvery time you start a new data analysis project, create a new
RStudio Project.
Because you want your project to work:
RStudio Projects create a convention that guarantees
that the project can be moved around on your computer or onto other
computers and will still “just work”: